#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "UserManager.h"
#include "TaskModel.h"
#include "RewardsModel.h"

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;
    // 注册TaskModel类到QML
    qmlRegisterType<TaskModel>("TaskModel", 1, 0, "TaskModel");
    qmlRegisterType<RewardsModel>("RewardsModel", 1, 0, "RewardsModel");
    // 将 UserManager 实例暴露给 QML
    // 创建 UserManager 实例
    UserManager *userManager = new UserManager();
    engine.rootContext()->setContextProperty("userManager", userManager);
    QObject::connect(
        &engine,
        &QQmlApplicationEngine::objectCreationFailed,
        &app,
        []() { QCoreApplication::exit(-1); },
        Qt::QueuedConnection);
    engine.loadFromModule("GHRewards", "Main");

    return app.exec();
}
